import 'package:dio/dio.dart';
import 'package:yybb_flutter/http/api_response.dart';
import 'package:yybb_flutter/http/http_utils.dart';
import 'package:yybb_flutter/modules/incremental_board/apiservise/incremental_board_api_servise.dart';
import 'package:yybb_flutter/modules/incremental_board/models/incremtal_board_culemodel.dart';
import 'package:yybb_flutter/modules/incremental_board/models/yybbincrementailCuleMode.dart';
import 'package:yybb_flutter/yybbtools/yybb_services.dart';

class IncrementaiBroadVmodel {

  /// 潜在客户
  static Future<ApiResponse<YYBBIncrementailCuleModeResultData>> getData(Map param) async {
    try {
      final response = await HttpUtils.get(
        potentialCustomersUrl,
        params:param,
      );
      Map dataMap = response;
      YYBBIncrementailCuleModeResultData item = YYBBIncrementailCuleModeResultData.fromJson(dataMap["resultData"]);
      return ApiResponse.completed(item);
    } on DioError catch (e) {
      return ApiResponse.error(e.error);
    }
  }


  /// 线索
  static Future<ApiResponse<YYBBIncrementailCuleMode>> getSearchCustomerData(Map param) async {
    try {
      final response = await HttpUtils.get(
        culeCustomerUrl,
        params:param,
      );
      Map dataMap = response;
      YYBBIncrementailCuleMode item = YYBBIncrementailCuleMode.fromJson(dataMap["resultData"]);
      return ApiResponse.completed(item);
    } on DioError catch (e) {

      return ApiResponse.error(e.error);
    }
  }


 /// 已下单客户
  static Future<ApiResponse<YYBBIncrementailCuleMode>> getOldCustomerData(Map param) async {
    try {
      final response = await HttpUtils.get(
        haveBuyUrl,
        params:param,
      );
      Map dataMap = response;
      YYBBIncrementailCuleMode item = YYBBIncrementailCuleMode.fromJson(dataMap["resultData"]);
      return ApiResponse.completed(item);
    } on DioError catch (e) {
      return ApiResponse.error(e.error);
    }
  }

  /// 已下单客户
  static Future<ApiResponse<YYBBIncrementailCuleMode>> getPassAgeData(Map param) async {
    try {
      final response = await HttpUtils.get(
        haveBuyUrl,
        params:param,
      );
      Map dataMap = response;
      YYBBIncrementailCuleMode item = YYBBIncrementailCuleMode.fromJson(dataMap["resultData"]);
      return ApiResponse.completed(item);
    } on DioError catch (e) {
      return ApiResponse.error(e.error);
    }
  }
}